package com.fitso.model.bean.nutrition;

import java.io.Serializable;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;

import com.fitso.model.bean.ModelBean;
import com.fitso.model.bean.measure.energy.Calorie;

/**
 * <p>
 * Food is the provision, to cells and organisms, of the materials necessary to
 * support life.
 * </p>
 * <p>
 * This Food is used to represent the nutritional label and/or food pyramid.
 * </p>
 * 
 * @author timothy storm
 * @see <a href="http://en.wikipedia.org/wiki/Nutrition">Nutrition</a>
 */
public class Food extends ModelBean implements Comparable<Food>, Serializable {
	// Only change on breaking changes, i.e., removing fields
	private static final long serialVersionUID = 1L;
	
	private Calorie _calories;

	private Carbohydrates _carbs;

	private Cholesterol _cholesterol;

	private Fats _fats;

	private FoodDescription _description;

	private Minerals _minerals;

	private Protein _protein;

	private Vitamins _vitamins;

	private Serving _serving;

	public Food() {
		super();
	}

	public int compareTo(Food other) {
		return new CompareToBuilder().append(_description, other._description).append(_calories, other._calories)
				.append(_carbs, other._carbs).append(_cholesterol, other._cholesterol).append(_fats, other._fats)
				.append(_protein, other._protein).append(_vitamins, other._vitamins).append(_minerals, other._minerals)
				.toComparison();
	}

	public boolean equals(Object o) {
		if (o == null) {
			return false;
		}
		if (o == this) {
			return true;
		}
		if (o.getClass() != getClass()) {
			return false;
		}

		Food other = (Food) o;
		return new EqualsBuilder().append(_description, other._description).append(_calories, other._calories).append(
				_carbs, other._carbs).append(_cholesterol, other._cholesterol).append(_fats, other._fats).append(
				_protein, other._protein).append(_vitamins, other._vitamins).append(_minerals, other._minerals)
				.isEquals();
	}

	public Calorie getCalories() {
		return _calories;
	}

	public Carbohydrates getCarbs() {
		return _carbs;
	}

	public Cholesterol getCholesterol() {
		return _cholesterol;
	}

	public Fats getFats() {
		return _fats;
	}

	public FoodDescription getDescription() {
		return _description;
	}

	public Minerals getMinerals() {
		return _minerals;
	}

	public Protein getProtein() {
		return _protein;
	}

	public Vitamins getVitamins() {
		return _vitamins;
	}

	public int hashCode() {
		return new HashCodeBuilder().append(_calories).append(_carbs).append(_cholesterol).append(_fats).append(
				_protein).append(_vitamins).append(_minerals).toHashCode();
	}

	public void setCalories(Calorie calories) {
		_calories = calories;
	}

	public void setCarbs(Carbohydrates carbs) {
		_carbs = carbs;
	}

	public void setCholesterol(Cholesterol cholesterol) {
		_cholesterol = cholesterol;
	}

	public void setFats(Fats fats) {
		_fats = fats;
	}

	public void setDescription(FoodDescription foodDescription) {
		_description = foodDescription;
	}

	public void setMinerals(Minerals minerals) {
		_minerals = minerals;
	}

	public void setProtein(Protein protein) {
		_protein = protein;
	}

	public void setVitamins(Vitamins vitamins) {
		_vitamins = vitamins;
	}

	public String toString() {
		return new ReflectionToStringBuilder(this).toString();
	}

	public void setServing(Serving serving) {
		_serving = serving;
	}

	public Serving getServing() {
		return _serving;
	}
}
